home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / v8n21.arc / TRIGDEMO.PAS < prev    next >
Pascal/Delphi Source File  |  1989-11-11  |  1KB  |  45 lines

  1. TRIGDEMO.PAS
  2.  
  3.  
  4.  
  5.  
  6.  
  7. PROGRAM TrigDemo;
  8. { This is an example to demonstrate use of the inverse
  9.   trigonometric function ArcSin (inverse sine).
  10.   The program calculates the angle of a right triangle with a
  11.   hypoteneuse "c" and a side "a" opposite the angle.
  12.   The user is prompted for the lengths of the opposide
  13.   side and of the hypoteneuse.  If the input is valid,
  14.   the program then displays the value of the angle in
  15.   degrees.}
  16. USES Trig, Crt;
  17.  
  18. VAR
  19.   a : Real;              {length of the side opposide the angle in question}
  20.   c : Real;              {length of the hypoteneuse}
  21.   ArcSinError : Boolean; {error return from ArcSin function}
  22.   angle : Real;          {the calculated angle}
  23.   Answer : Char;         { answer to done prompt}
  24. BEGIN
  25.   ClrScr;
  26.   REPEAT
  27.     Write('Input the length of the side opposite ');
  28.     Write('the angle in question> ');
  29.     ReadLn(a);
  30.     Write('Input the length of the hypoteneuse> ');
  31.     ReadLn(c);
  32.     {calculate the angle and convert it to degrees.}
  33.     angle := 360.0*ArcSin(a/c, ArcSinError)/(2.0*Pi);
  34.     IF ArcSinError THEN
  35.       WriteLn('***** ERROR in inverse sine calculation *****')
  36.     ELSE WriteLn('The angle is ', angle:1:11);
  37.     WriteLn;
  38.     Write('Are you done? ');
  39.     Answer := Upcase(ReadKey); WriteLn(Answer);
  40.   UNTIL Answer = 'Y';
  41. END.
  42.  
  43.  
  44.  
  45.